package com.zeny.coding.dto;


import com.zeny.coding.util.DtoUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.util.StringUtils;

import javax.xml.bind.ValidationException;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class CourseContentFileDto {
    private String id;

    private String courseId;

    private String url;

    private String name;

    private Integer size;

    public void isValidForSave() throws ValidationException {
        DtoUtil.valid(this.courseId, true, 1, 19);
        DtoUtil.valid(this.url, true, 1, 100);
        DtoUtil.valid(this.name, true, 1, 100);
        DtoUtil.require(this.size);
        if (!StringUtils.isEmpty(this.id)) {
            this.id = null;
        }
    }
}